<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('添加考勤信息变动信息')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<style>
    .select2 {
        width: 100% !important;
    }
</style>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-retire-edit" AUTOCOMPLETE="OFF">
        <div class="form-group">
            <label class="col-sm-3 control-label ">登记日期：</label>
            <div class="col-sm-8">
                <input class="form-control" name="term" id="term" type="text" readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">工号：</label>
            <div class="col-sm-8">
                <input class="form-control" name="badge" id="badge" type="text" onblur="findPerson()"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">姓名：</label>
            <div class="col-sm-8">
                <input type="hidden" name="eid" id="eid"/>
                <input class="form-control" name="name" id="name" type="text" readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">公司名称：</label>
            <div class="col-sm-8">
                <input type="hidden" name="compid" id="compid"/>
                <input class="form-control" name="compName" id="compName" type="text" readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">部门名称：</label>
            <div class="col-sm-8">
                <input type="hidden" name="depid" id="depid"/>
                <input class="form-control" name="depName" id="depName" type="text" readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">岗位名称：</label>
            <div class="col-sm-8">
                <input type="hidden" name="jobid" id="jobid"/>
                <input class="form-control" name="jobName" id="jobName" type="text" readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">考勤员工类型：</label>
            <div class="col-sm-8">
                <input type="hidden" name="atEmpTypeId" id="atEmpTypeId"/>
                <input class="form-control" name="atEmpType" id="atEmpType" type="text" readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">新考勤员工类型：</label>
            <div class="col-sm-8">
                <select name="atEmpTypeNew" id="atEmpTypeNew" class="form-control">
                    <option value="">请选择</option>
                    <option th:each="atEmpType : ${atEmpType}" th:text="${atEmpType.title}"
                            th:value="${atEmpType.id}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">开始日期：</label>
            <div class="col-sm-8">
                <input class="form-control" name="beginDate" id="beginDate" type="text"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">备注：</label>
            <div class="col-sm-8">
                <input class="form-control" name="remark" id="remark" type="text"/>
            </div>
        </div>
    </form>
</div>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>

<script th:inline="javascript">

    var prefix = ctx + "attendEmpManage/AttendChange";

    $(function () {
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#beginDate',
                type: 'date'
            });
        });
        var date = new Date();
        $("#term").val(date.toLocaleDateString());
    });

    function findPerson() {
        var badge = $("#badge").val();
        $.ajax({
            async: false,
            url: prefix + "/findPerson",
            data: {
                "badge": badge
            },
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.msg == "error") {
                    $.modal.alertError("错误,员工号不存在请重新输入！");
                }
                $("#eid").val(data.eid);
                $("#name").val(data.name);
                $("#compid").val(data.compid);
                $("#compName").val(data.compName);
                $("#depid").val(data.depid);
                $("#depName").val(data.depName);
                $("#jobid").val(data.jobid);
                $("#jobName").val(data.jobName);
                $("#atEmpTypeId").val(data.atEmpTypeId);
                $("#atEmpType").val(data.atEmpType);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                //$.modal.alertError("错误,员工号不存在请重新输入！");
            }
        });
    }

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-retire-edit").serializeArray();
            var badge = $("#badge").val();
            if (badge.length == 0) {
                $.modal.alertWarning("请输入员工工号!");
                return;
            }
            $.operate.save(prefix + "/save", data);
        }
    }

</script>


</body>
</html>